package vn.co.thn.android.store.adapter;

import java.util.List;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import vn.co.thn.android.store.NSApp;
import vn.co.thn.android.store.R;
import vn.co.thn.android.store.data.NSCategoryItemData;

public class NSCategoryListAdapter extends NSCommonAdapter<NSCategoryItemData> {

	public NSCategoryListAdapter(Context context, List<NSCategoryItemData> objects) {
		super(context, R.layout.ns_left_item_list, objects);
	}

	@SuppressLint("InflateParams") @Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = convertView;
		ViewHolder viewHolder;
		if (view == null) {
			view = mInflater.inflate(R.layout.ns_left_item_list, null);
			viewHolder = new ViewHolder();
			viewHolder.name = (TextView) view.findViewById(R.id.name);
			viewHolder.image = (ImageView) view.findViewById(R.id.image);
			view.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) view.getTag();
		}
		NSApp.Load_Image(getItem(position).getImage_Url(), viewHolder.image);
		viewHolder.name.setText(getItem(position).getName());
		return view;
	}

	private class ViewHolder {
		ImageView image;
		TextView name;
	}
}
